package com.hz.ruoyimotor.api;/**
 * @Author tjh
 * @Date 2025/3/6 15:26
 * @version 1.0
 * @注释
 */

import com.hz.rouyigonggong.utils.ResultJSON;
import com.hz.ruoyimotor.mapper.LgDriverMapper;
import com.hz.ruoyimotor.mapper.LgVehicleMapper;
import com.hz.ruoyimotor.service.LgDriverService;
import com.hz.ruoyimotor.service.LgVehicleService;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ClassName LgMotorApi
 * @Description TODO
 * @Author tjh
 * @Date 2025/3/6 15:26
 * @Version 1.0
 */
@RestController
@RequestMapping("/api")
public class LgMotorApi {
    @Autowired
    private LgVehicleService lgVehicleService;
    @Autowired
    private LgDriverMapper lgDriverMapper;
    @Autowired
    private LgDriverService lgDriverService;

    @GetMapping("/list")
    public AjaxResult getAlldriver(@RequestParam Map<String, Object> params, Integer pageNum, Integer pageSize)
    {
        Integer firstNum = (pageNum-1)*pageSize;
        Integer secondNum = pageSize;
        return  AjaxResult.success(lgDriverService.getReallyList(params,firstNum,secondNum));
    }
@GetMapping("/getTotalDriver")
public int getTotalDriver(){
    return lgDriverService.getCountDriver();
}

@GetMapping("/getTotalVehicle")
    public int getTotalVehicle(){
        return lgVehicleService.getCountVehicle();
    }
@RequiresPermissions("motor:vehicle:getAll")
@RequestMapping("/getAll")
public ResultJSON getAll(Integer vehicleType, Double vehicleLength,
                         Double vehicleVolume,
                         Integer licenseType,
                         String licensePlate,
                         Integer vehicleStatus,
                         String beginTime,
                         String endTime, Integer pageNum, Integer pageSize,String createBy){

    Integer firstNum = (pageNum-1)*pageSize;
    Integer secondNum = pageSize;

    //完成分页
    return ResultJSON.success(lgVehicleService.getReallyList(vehicleType, vehicleLength,
            vehicleVolume,
            licenseType,
            licensePlate,vehicleStatus,
            beginTime,
            endTime,
            firstNum,secondNum,createBy));
}
}
